<% layout('/layouts/default.html', {title: '文件领取', libs: ['dataGrid']}){ %>
<style>
    .camera{
        height: 30px;
        background-color: #ffffff;
        border-color: #1E5EDB;
        color: #1E5EDB;
        margin-top:25px;
    }

</style>

<div class="main-content">




          <div class="row" >
            <div class="col-xs-5 "  >
                            <div class="form-group ">
                                <label class="control-label col-sm-4">${text('姓名')}：</label>

                                <div class="col-sm-8">
                                    <#form:input  title="姓名" path="userCode"  value="${userName}" class="form-control" onchange="chang()"  id="userName"/>

                                </div>
                            </div>
             </div>
                        <div class="col-xs-5">
                                        <div class="form-group ">
                                            <label class="control-label col-sm-4">${text('警号')}：</label>

                                            <div class="col-sm-8">
                                                <#form:input  value="${police}" readonly="true"  class="form-control" onchange="jhChange()"  id="userPolice"/>
                                              <#form:input   value="${userCode}" path="userCodes" type="hidden"  class="form-control "  id="userCodes"/>
                                            </div>
                                        </div>
                        </div>
                       <div class="col-xs-10" style="display:none;" id="face">
                                       <div class="form-group">


                                           <div class="col-sm-8">
                                            <img style="height: 150px;margin-left:35%;cursor: pointer;border-radius: 150px" id="showImg" src="${ctxStatic}/camera.jpg"  title="预览" onclick="collectPicture()">

                                            <input  type="hidden"  class="form-control width-120"  id="pictureSrc"/>
                                           </div>
                                </div>
                       </div>
          </div>



</div>
</div>
</form>
</div>


<div style="display:none;margin:10px;" id="sho">


</div>

<%}%>



<script>
function chang(){
   document.getElementById("userPolice").removeAttribute("readonly")
document.getElementById("face").style.display="block"
   document.getElementById("userCodes").value=""
}
function jhChange(){
document.getElementById("userCodes").value=""
}
   function collectPicture(){
            js.layer.open({
                type: 2,
                area: [(js.layer.window.outerWidth-350)+'px',(js.layer.window.outerHeight-200)+'px'],
                title: '${text("拍照")}',
                resize: false,
                scrollbar: true,
                maxmin:true,
                content: '${ctx}/sd/collectPicture/form',
                success: function(layero, index){

                },
                btn: ['<i class="fa fa-check"></i> ${text("上传")}',
                    '<i class="fa fa-remove"></i> ${text("关闭")}'],
                btn1: function (index, layero) {
                    var win = layero.iframeWindow();
                    if (typeof(win.getFile()) == "undefined"){
                        js.layer.msg('请先拍照再提交!', {icon: 5});
                        return false;
                    }
                    console.log(typeof (win.getFile()));
                    var formData = new FormData;
                    formData.append("file", win.getFile());
                    $.ajax({
                        type: "POST",
                        url: "${ctx}/sd/collectPicture/uploadFile",
                        data: formData,
                        contentType: false,
                        processData: false,
                        success: function (data) {
                            if(data.result===Global.TRUE){
                                js.layer.msg(data.message, {icon: 1});
                                js.layer.close(index);
                                $('#pictureSrc').val(data.data);
                                $("#showImg").attr("src",win.getUrl());

                                return true;
                            }else {
                                js.layer.msg(data.message, {icon: 5});
                                return false;
                            }

                        }
                    })
                    return false;

                }


            });
        }
</script>







